<?php
declare(strict_types=1);

namespace App\Admin\Middleware;

use Newbie\Crontab\NewbieCrontabManage;
use Newbie\Exception\TokenException;
use Newbie\Helper\NewbieCode;
use Webman\Http\Request;
use Webman\Http\Response;
use Webman\MiddlewareInterface;

class AuthMiddleware implements MiddlewareInterface {

    protected string $scene = 'default';

    /**
     */
    public function process (Request $request, callable $handler): Response {
        $scene     = $auth->scene ?? 'default';
        $loginUser = user($scene);
        if (!$loginUser->check(null, $this->scene)) {
            throw new TokenException(t('jwt.validate_fail'), NewbieCode::TOKEN_EXPIRED);
        }
        return $handler($request);
    }
}